-program example
use polymorphic_complextaylor
implicit none 
integer no,nv,i
complex(dp) c,cc,ccc
type(double_complex) f,g

integer, allocatable :: j(:),k(:) 

no=4; nv= 2;    ! no: the order of the polynomial    nv: the number of variables   
call init(no,nv)  ! initializes taylor series without maps

call alloc(f,g)      ! must be constructed after init

allocate(j(nv))
allocate(k(nv))
 
j=0
j(1)=1;j(2)=2;

k=0
k(1)=3;k(2)=1;

cc=cmplx(5.d0,-1.4d0,kind=dp)
ccc=cmplx(6.d0,1.6d0,kind=dp)  


f=(cc.mono.j)  + (ccc.mono.k) + 3.d0    !   <---------- changed
   !  Creates 5.d0 x_1 x_ 2 ^2 - 1.4d0 i* x_1 x_ 2 ^2 + 6.d0 x_1^3 x_2+ 1.6d0 i* x_1^3 x_2 + 3.d0
c=f.sub.j     ! Peeks coefficient   5.d0 - 1.4d0 i

call print( f,6)
write(6,*) c


f=cc
c=f.sub.j     ! Returns zero

call print( f,6)
write(6,*) c



f=(cc.mono.'12' ) + (cc.mono.'13' ) + ( ccc.mono.'01')  + 3.d0
   ! Creates 5.d0 x_1 x_ 2 ^2 - 1.4d0 i* x_1 x_ 2 ^2 + 5.d0 x_1 x_ 2 ^3 - 1.4d0 i* x_1 x_ 2 ^3 + 6.d0 x_2 + 1.6d0 i* x_2 + 3.d0
c=f.sub.'13'        ! Peeks coefficient   5.d0 - 1.4d0 i

call print( f,6)
write(6,*) c



f=cc
c=f.sub.'13'    ! Returns zero

call print( f,6)
write(6,*) c


deallocate(j)
call kill(f,g)      ! must be destroyed
end program example
